<script type="text/javascript">
$(function(){
	var pg = App.auth.sysFuncEdit.ui, pp = pg.params || {};
	var frm = {
		code: pg.seek('code'), // 角色编号
		type: pg.seek('type'), // 分类
		name: pg.seek('name'), // 功能编码
		uri: pg.seek('uri'), // 功能网址
		no: pg.seek('no'), // 功能网址
		status: pg.seek('status'), // 0未启用，1启用
		memo: pg.seek('memo') // 备注
	};
	frm.status.mac('combo', {
		width: 340,
		boxWidth: 340,
		data: Cache.auth.func.status
	});
	function getValues(){
		return {
			code: frm.code.val(),
			type: frm.type.val(),
			name: frm.name.val(),
			uri: frm.uri.val(),
			no: frm.no.val(),
			status: frm.status.val(),
			memo: frm.memo.val(),
			flag: pp.flag
		};
	}
	function setValues(o){
		pg.children('.title').html(o.id? '编辑接口信息':'添加接口');
		frm.code.val(o.code);
		frm.type.val(o.type);
		frm.name.val(o.name);
		frm.uri.val(o.uri);
		frm.no.val(o.no);
		frm.status.val([o.status]);
		frm.memo.val(o.memo);
	}
	function validate(p){
		var m = pg.seek('msg').html(''), v = App.base.validation, x = App.validate;
		return !x(v.func.code, p.code, m, '角色编号')&&
			!x(v.func.name, p.name, m, '功能编码')&&
			!x(v.func.status, p.status, m, '状态');
	}
	pg.find('input').blur(function(){
		var pms = getValues();
		if (!validate(pms))
			return;
	});
	pg.seek('ok').click(function(){
		var pms = getValues();
		if (!validate(pms))
			return;
		$.post(App.auth.ctx + '/sys/func/save.do', pms, function(rs){
			var ro = mac.eval(rs);
			if (ro.success) {
				pg.close();
				pg.callback();
			} else {
				pg.seek('msg').html(mac.msg(ro.data, ro.params));
			}
		});
		return false;
	}).show();
	setValues(pp);
	//如果是修改，則不能修改code值
	if (pp.code){
		frm.code.attr('readonly', true).css('border', 'none');
	}
});
</script>
<div class="form">
	<h3 class="title hidden">系统模块配置</h3>
	<div class="item">
		<span class="label">编号：</span> 
		<input type="text" name="code"/>
		<span class="msg">*</span>
		<div class="clear"></div>
	</div>
	<div class="item">
		<div class="label">分类：</div>
		<input type="text" name="type"/>
		<div class="clear"></div>
	</div>
	<div class="item">
		<span class="label">名称：</span> 
		<input type="text" name="name" /> 
		<span class="msg">*</span>
		<div class="clear"></div>
	</div>
	<div class="item">
		<span class="label">地址：</span> 
		<input type="text" name="uri" /> 
		<div class="clear"></div>
	</div>
	<div class="item">
		<span class="label">序号：</span> 
		<input type="number" name="no" /> 
		<div class="clear"></div>
	</div>
	<div class="item">
		<span class="label">状态：</span>
		<div class="combo fl" name="status"></div>
		<span class="msg">*</span>
		<div class="clear"></div>
	</div>
	<div class="item">
		<span class="label">备注：</span>
		<textarea name="memo"></textarea>
		<span class="msg">*</span>
		<div class="clear"></div>
	</div>
	<div class="item">
		<span class="label">&nbsp;</span>
		<div name="msg" class="msg"></div>
		<div class="clear"></div>
	</div>
	<div class="bottom">
		<button name="ok">保存</button>
	</div>
</div>